<template>
	<view class="collection-page">
		<navgatsVue :navigationMsg="navigationMsg"></navgatsVue>
		<view class="main">
			<view class="collectionList">
				<view class="collectionListBox">
					<view class="collectionList-item" v-for="(item,index) in Colldata" :key="index"
						@click="ondeilts(index)">
						<view class="imgbox">
							<img class="img" :src="'https://api.jingkakeji.com/' + item.goodsProducts.images[0]"
								alt="" />
						</view>
						<view class="info">
							<view class="text">
								{{item.goodsProducts.shorttitle}}
							</view>
							<view class="price">
								￥<span>1.2</span>/天
							</view>
						</view>
					</view>
				</view>
			</view>
			<view class="recommend">
				<view class="title">
					为你推荐
				</view>
				<phoneListVue :phoneList="phoneList"></phoneListVue>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		Collent,
		Page
	} from "../../../api/api.js"
	import navgatsVue from '../../../common/navgats/navgats.vue';
	import phoneListVue from '../../../common/my/phone-list/phone-list.vue';
	export default {
		data() {
			return {
				navigationMsg: {
					title: "收藏",
					bgColor: "#f6f6f6"
				},
				Colldata: [],
				phoneList: []
			}
		},
		components: {
			navgatsVue,
			phoneListVue
		},
		mounted() {
			this.Collents()
			this.onpages()
		},
		methods: {
			async onpages() {
				let res = await Page()
				if (res.data.code == 1) {
					this.phoneList = res.data.data.clearance
				}
			},
			ondeilts(index) {
				uni.navigateTo({
					url: `/pages/detail/detail?id=${this.Colldata[index].goods_products_id}`
				})
			},
			async Collents() {
				let data = {
					page: 1,
					limit: 10
				}
				let res = await Collent(data)
				if (res.data.code == 1) {
					this.Colldata = res.data.data.list;
					console.log(this.Colldata);
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.collection-page {
		width: 100vw;
		height: 100vh;

		.main {
			width: 100%;
			height: calc(100vh - 180rpx);
			background-color: #f6f6f6;
			display: flex;
			flex-direction: column;
			align-items: center;
			overflow-y: scroll;

			.collectionList {
				width: 95%;

				.collectionListBox {
					width: 100%;
					display: flex;
					flex-direction: column;
					align-items: center;

					.collectionList-item {
						width: 100%;
						height: 250rpx;
						background-color: white;
						display: flex;
						align-items: center;
						justify-content: space-between;
						margin-top: 20rpx;
						border-radius: 20rpx;

						.imgbox {
							width: 250rpx;
							height: 250rpx;
							display: flex;
							justify-content: center;
							align-items: center;

							.img {
								max-width: 80%;
								max-height: 80%;
							}
						}

						.info {
							width: 480rpx;
							height: 160rpx;
							margin-right: 20rpx;
							display: flex;
							flex-direction: column;
							justify-content: space-between;

							.text {
								font-size: 29rpx;
							}

							.price {
								color: red;

								>span {
									font-weight: bold;
									font-size: 36rpx;
								}
							}
						}
					}
				}
			}

			.recommend {
				width: 95%;

				.title {
					width: 100%;
					height: 100rpx;
					line-height: 100rpx;
					text-align: center;
					font-size: 36rpx;
					font-weight: bold;
				}
			}
		}
	}
</style>